//引入文件
import Vue from 'vue'
import Vuex from 'vuex'
//使用
Vue.use(Vuex);

export default new Vuex.Store({//创建仓库
   state: {//存放公共数据
      city: localStorage.city || "北京"
   },
   actions: {
      changeCity (ctx,city) {
         ctx.commit('changeCity',city);
      }
   },
   mutations :{
      changeCity (state,city){
          state.city = city;
          localStorage.city = city;
      }
   }
})
